const Model = require("../models/Model");
let status = function (data, res) {
  if (data) {
    res.send({
      meta: {
        status: 200,
        msg: "添加成功",
      },
      data,
    });
    return;
  } else {
    res.send({
      meta: {
        status: 500,
        msg: "添加失败",
      },
      data: null,
    });
  }
  res.send(data);
};
module.exports = {
  async getAll(req, res) {
    let data = await Model.frontend.find({}).catch((err) => console.log(err));
    res.send(data);
  },
  async getSearchValue(req, res) {
    let { searchValue } = req.query;
    let reg = new RegExp(searchValue, "i");
    let data = await Model.frontend
      .find({ courseName: { $regex: reg } })
      .catch((err) => console.log(err));
    console.log(data);
    res.send(data);
  },
};
